/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.trace;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "trace_user_account")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TraceUserAccount.findAll", query = "SELECT t FROM TraceUserAccount t"),
    @NamedQuery(name = "TraceUserAccount.findBySid", query = "SELECT t FROM TraceUserAccount t WHERE t.sid = :sid"),
    @NamedQuery(name = "TraceUserAccount.findByTraceType", query = "SELECT t FROM TraceUserAccount t WHERE t.traceType = :traceType"),
    @NamedQuery(name = "TraceUserAccount.findById", query = "SELECT t FROM TraceUserAccount t WHERE t.id = :id"),
    @NamedQuery(name = "TraceUserAccount.findByUserID", query = "SELECT t FROM TraceUserAccount t WHERE t.userID = :userID"),
    @NamedQuery(name = "TraceUserAccount.findByAccountCode", query = "SELECT t FROM TraceUserAccount t WHERE t.accountCode = :accountCode"),
    @NamedQuery(name = "TraceUserAccount.findByAccessID", query = "SELECT t FROM TraceUserAccount t WHERE t.accessID = :accessID"),
    @NamedQuery(name = "TraceUserAccount.findByReMark", query = "SELECT t FROM TraceUserAccount t WHERE t.reMark = :reMark"),
    @NamedQuery(name = "TraceUserAccount.findByAlterUserID", query = "SELECT t FROM TraceUserAccount t WHERE t.alterUserID = :alterUserID"),
    @NamedQuery(name = "TraceUserAccount.findByCreateTime", query = "SELECT t FROM TraceUserAccount t WHERE t.createTime = :createTime"),
    @NamedQuery(name = "TraceUserAccount.findByTimeStamp", query = "SELECT t FROM TraceUserAccount t WHERE t.timeStamp = :timeStamp")})
public class TraceUserAccount implements Serializable {
	public static byte[] EnCode(TraceUserAccount msg) throws IOException {
		Codec<TraceUserAccount> Lcode = ProtobufProxy.create(TraceUserAccount.class);
		return Lcode.encode(msg);
	}
	public static TraceUserAccount DeCode(byte[] data) throws IOException {
	Codec<TraceUserAccount> Lcode = ProtobufProxy.create(TraceUserAccount.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "sid")
    @Protobuf
	private Integer sid;
    @Basic(optional = false)
    @Column(name = "TraceType")
    @Protobuf
	private String traceType;
    @Basic(optional = false)
    @Column(name = "id")
    @Protobuf
	private int id;
    @Basic(optional = false)
    @Column(name = "UserID")
    @Protobuf
	private String userID;
    @Basic(optional = false)
    @Column(name = "AccountCode")
    @Protobuf
	private String accountCode;
    @Column(name = "AccessID")
    @Protobuf
	private String accessID;
    @Column(name = "ReMark")
    private String reMark;
	@Protobuf
	private byte[] reMarkBit;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public TraceUserAccount() {
    }

    public TraceUserAccount(Integer sid) {
        this.sid = sid;
    }

    public TraceUserAccount(Integer sid, String traceType, int id, String userID, String accountCode) {
        this.sid = sid;
        this.traceType = traceType;
        this.id = id;
        this.userID = userID;
        this.accountCode = accountCode;
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public String getTraceType() {
        return traceType;
    }

    public void setTraceType(String traceType) {
        this.traceType = traceType;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public String getAccountCode() {
        return accountCode;
    }

    public void setAccountCode(String accountCode) {
        this.accountCode = accountCode;
    }

    public String getAccessID() {
        return accessID;
    }

    public void setAccessID(String accessID) {
        this.accessID = accessID;
    }

    public String getReMark() {
        return reMark;
    }

    public void setReMark(String reMark) {
        this.reMark = reMark;
        this.setReMarkBit(CodeTool.StringToBit(reMark));
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sid != null ? sid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TraceUserAccount)) {
            return false;
        }
        TraceUserAccount other = (TraceUserAccount) object;
        if ((this.sid == null && other.sid != null) || (this.sid != null && !this.sid.equals(other.sid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.trace.TraceUserAccount[ sid=" + sid + " ]";
    }

    public byte[] getReMarkBit() {
        return reMarkBit;
    }

    public void setReMarkBit(byte[] reMarkBit) {
        this.reMarkBit = reMarkBit;
		this.reMark = CodeTool.BitToString(reMarkBit);
    }
    
}
